package org.easystub;

import java.lang.reflect.Method;

public final class Invocation {

    private final Object objectCalled;
    private final Method methodCalled;
    private final Object[] methodArguments;

    public Invocation(Object objectCalled, Method methodCalled) {
        this(objectCalled,methodCalled, null);
    }

    public Invocation(Object objectCalled, Method methodCalled, Object[] methodArguments) {
        this.objectCalled = objectCalled;
        this.methodCalled = methodCalled;
        this.methodArguments = methodArguments;
    }

    public Object getObjectCalled() {
        return objectCalled;
    }

    public Method getMethodCalled() {
        return methodCalled;
    }

    public Object[] getMethodArguments() {
        return methodArguments;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Invocation that = (Invocation) o;

        return methodCalled.equals(that.methodCalled) && objectCalled.equals(that.objectCalled);

        }

    @Override
    public int hashCode() {
        int result = objectCalled.hashCode();
        result = 31 * result + methodCalled.hashCode();
        return result;
    }
}
